package org.csu.sei.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.csu.sei.entity.ReadAmount;
import org.csu.sei.entity.Statistics;
import org.csu.sei.persistence.ReadAmountMapper;
import org.csu.sei.persistence.StatisticsMapper;
import org.csu.sei.service.IReadAmountService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component(value = "readAmountService")
public class ReadAmountServiceImpl extends ServiceImpl<ReadAmountMapper,ReadAmount> implements IReadAmountService {

    @Resource
    private ReadAmountMapper readAmountMapper;

    @Resource
    private StatisticsMapper statisticsMapper;

    @Override
    public void clearAll(){
        readAmountMapper.update(null,new UpdateWrapper<ReadAmount>().set("count",0));
    }

    @Override
    public int getMonReade(int year,int month) {
        return statisticsMapper.selectMonRead(year,month);
    }
}
